package com.sample.xcrash;


import com.sample.xcrash_lib.XCrash;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class MyApplicationTest {

    private final String filePath = XCrash.getLogDir();

    Init init = new Init();

    @Before
    public void setUp() throws Exception {
        assertNotNull(filePath);
        init.setUp();
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void getExternalFilesDirTest() {

        final String filesDir = init.currentTopAbility.getExternalFilesDir("xcrash").toString();
        assertEquals(filePath, filesDir);
    }

    @Test
    public void xCrashInitTest() {
        String[] newParams = new String[]{"A", "B"};
        XCrash.InitParameters initParameters = new XCrash.InitParameters().setJavaDumpAllThreadsWhiteList(newParams);
        assertEquals("A", newParams[0]);
        assertEquals(-3, XCrash.init(init.mContext, initParameters));
    }

    @Test
    public void xCrashInitparamsTest() {
        assertEquals(-3, init.xcrash_Init);
    }

    @Test
    public void getLogDir() {
        String dir = XCrash.getLogDir();
        assertEquals(filePath, dir);
    }

}
